package pri.lt.parser;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import edu.uci.ics.crawler4j.parser.HtmlParseData;

import java.util.Date;
import java.util.List;

public interface Parser {


    ParserResult parse(String url);

    HotCommentResult getHotCommentResult(String url,  Parser.ParserResult parserResult);

    public static class  ParserResult {
        public String title;
        public String content;
        public Date publishTime;
        public String thumbnailUrl;
        //public String allHtml;
        public String commentUrl;

        public boolean isValid() {

            if (title == null || title.trim().length() == 0) {
                return false;
            }

            if (content == null || content.trim().length() == 0) {
                return false;
            }

            if (publishTime == null) {
                return false;
            }

            if (thumbnailUrl == null || thumbnailUrl.trim().length() == 0) {
                return false;
            }

//            if (commentUrl == null || commentUrl.trim().length() == 0) {
//                return false;
//            }

            return  true;
        }
    }

    public static class  HotCommentResult {
        public boolean isHot = false;
        public int commentCount = 0;
        public List<HotComment> comments;
        public double crawlerReplyRankCount;
    }

    public static class HotComment {
        public String username;
        public String avatarUrl;
        public String content;
    }

    public boolean isDomainSupport(String url);

    public boolean isUrlCanParse(String url);

    public boolean isDomainDirectory(String url);



}
